package com.atguigu.gmall.mq.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.mq.config.RabbitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 发送消息
 */
@RestController
@RequestMapping(value = "/rabbit")
public class MqController {
    @Autowired
    private RabbitService rabbitService;
    /**
     * 测试发送消息
     */
    @GetMapping(value = "/sendConfirm")
    public Result sendConfirm(){
        for (int i = 1; i <= 20; i++) {
            rabbitService.sendMessage("java_exchange", "java.confirm", "测试消息" + i);
        }

        return Result.ok("发送完成");
    }
}
